//
//  OrderDetailFooterCell.m
//  PigMarket
//
//  Created by 张敬 on 2019/9/11.
//  Copyright © 2019年 pigmarket.oc. All rights reserved.
//

#import "OrderDetailFooterCell.h"

@implementation OrderDetailFooterCell

#pragma mark - lifecycle methods

- (void)setupUI{
    
    [self addSubview:self.cameraLab];
    [self addSubview:self.friendLab];
}

- (void)setupLayout{
    
    _cameraLab.size = _friendLab.size = CGSizeMake((KScreenWidth- 30)/2.0, 42);
    _cameraLab.mj_y = _friendLab.mj_y = 0;
    _cameraLab.mj_x = 0;
    _friendLab.mj_x = (KScreenWidth - 30)/2.0;
    
    //横线
    CAShapeLayer *line = [CAShapeLayer layer];
    line.fillColor = UIColorFromRGB(0xF2F2F2).CGColor;
    
    UIBezierPath *path = [UIBezierPath bezierPathWithRect:CGRectMake(0, 0, KScreenWidth - 30, 0.5)];
    line.path = path.CGPath;
    [self.layer addSublayer:line];
    
    //竖线
    CAShapeLayer *line1 = [CAShapeLayer layer];
    line1.fillColor = UIColorFromRGB(0xF2F2F2).CGColor;
    
    UIBezierPath *path1 = [UIBezierPath bezierPathWithRect:CGRectMake((KScreenWidth - 30)/2.0, 11, 1, 20)];
    line1.path = path1.CGPath;
    [self.layer addSublayer:line1];
}


#pragma mark - setter methods

- (void)setType:(OrderDetailFooterCellType)type{
    
    NSMutableAttributedString *cameraText;
    NSMutableAttributedString *chatText;
    
    switch (type) {
            
        case OrderDetailFooterCellType_SeePig:
        {
            cameraText = [@" 打开监控" createAttributingByIcon:@"camera_seepig" downIndexImage:nil textColor:UIColorFromRGB(0x6B6B6B) font:mMediumFont(14)];
            _cameraLab.attributedText = cameraText;
        }
            break;
            
        case OrderDetailFooterCellType_OpenCamera:
        {
            cameraText = [@" 打开监控" createAttributingByIcon:@"mine_order_opencamera" downIndexImage:nil textColor:UIColorFromRGB(0xACACAC) font:mMediumFont(14)];
            _cameraLab.attributedText = cameraText;

        }
            break;
            
        case OrderDetailFooterCellType_Chat:
        {
            chatText = [@" 聊一聊" createAttributingByIcon:@"chat_green" downIndexImage:nil textColor:UIColorFromRGB(0x6B6B6B) font:mMediumFont(14)];
            _friendLab.attributedText = chatText;

        }
            break;
            
        case OrderDetailFooterCellType_AddFriend:
        {
            chatText = [@" 加好友" createAttributingByIcon:@"chat_chat" downIndexImage:nil textColor:UIColorFromRGB(0x6B6B6B) font:mMediumFont(14)];
            _friendLab.attributedText = chatText;

        }
            break;
            
        default:
            break;
    }
    
}


#pragma mark - getter methods

- (UILabel *)cameraLab{
    
    if (!_cameraLab) {
        _cameraLab = [UILabel new];
        _cameraLab.textAlignment = 1;
    }
    return _cameraLab;
}

- (UILabel *)friendLab{
    
    if (!_friendLab) {
        _friendLab = [UILabel new];
        _friendLab.textAlignment = 1;
    }
    return _friendLab;
}

@end
